<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$category.name} {$category.page_title} {$site_info.site_name|default=''}</title>
<meta name="keywords" content="{$category.page_keywords},{$site_info.site_seo_keywords|default=''}"/>
<meta name="description" content="{$category.page_description},{$site_info.site_seo_description|default=''}">
<include file="public@head"/>

</head>
<body>
    
    <include file='public@nav'/>

    <!-- banner -->
    <include file='public@banner'/>

    <div class="main layout clearfix">

        <!-- category -->
        <include file='public@category'/>
        
        <div class="oright fr">
            <!-- 面包 -->
            <include file='public@breadcrumb'/>

            <style type="text/css">
                .content .item{min-height: 60px;height: auto;line-height: 60px;}
                .content .item span{width: 100px;font-size: 14px;display: inline-block;vertical-align: middle;color:#333;}
                .content .item input{font-size: 14px;vertical-align: middle;height: 35px;line-height: 35px;padding: 0 10px;border:1px solid #e3e3e3;width: 400px;}
                .content .con{vertical-align: top;width: 640px;height: 200px;border: 1px solid #e3e3e3;resize: none;padding:2px 10px;}
                .content .msg_sub{width:200px !important;background: #e40001;border:#e40001 1px solid !important;color:#fff;}
                .help-block{color:red;}
            </style>

            <div class="content">
               <form method="POST" action='{:cmf_url('api/guestbook/addmsg')}' onsubmit="formSubmit();return false;" id="theForm">
                    <div class="item">
                        <span>姓名：</span>
                        <input type="text" name="post[full_name]" value="" id='full_name'>
                        <i class='help-block'></i>
                    </div>
                    <div class="item">
                        <span>电话：</span>
                        <input type="text" name="post[phone]" value="" id='phone'>
                        <i class='help-block'></i>
                    </div>
                    <div class="item">
                        <span>邮箱：</span>
                        <input type="text" name="post[email]" value="" id='email'>
                        <i class='help-block'></i>
                    </div>
                    <div class="item" style="padding-top:15px;">
                        <span>内容：</span>
                        <textarea name="post[msg]" value="" class='con' id='msg'></textarea>
                        <i class='help-block'></i>
                    </div>
                    <div class="item">
                        <span></span>
                      
                        <input type="submit" value="提交留言" class="msg_sub" data-wait="1500">
                        <i class='help-block'></i>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <include file='public@footer'/>

</body>
</html>

<include file='public@scripts'/>

<script type="text/javascript">
    
    // ajax提交留言
    function formSubmit(){
        var full_name = $('#full_name').val();
        var phone     = $('#phone').val();
        var email     = $('#email').val();
        var msg       = $('#msg').val();

        
        $('.help-block').html('');
        if( full_name =='' ){

            $('#full_name').siblings('.help-block').html('{$lang["full_name_require"]}');
            return false;
        }

        //验证联系电话
        if( phone =='' ){

            $('#phone').siblings('.help-block').html('{$lang["phone_require"]}');
            return false;
        }

        reg = /^13[0-9]{1}[0-9]{8}$|14[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|17[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$|19[0-9]{1}[0-9]{8}$/;
        if (!reg.test(phone)) {
           
            $('#phone').siblings('.help-block').html('{$lang["please_correct_phone"]}');
            return false;
        }

        //验证邮箱
        if( email =='' ){
            
            $('#email').siblings('.help-block').html('{$lang["email_require"]}');
            return false;
        }
        reg = /([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i;
        if (!reg.test(email)) {
            
            $('#email').siblings('.help-block').html('{$lang["please_correct_email"]}');
            return false;
        }

       
        
        if( msg =='' ){
            
            $('#msg').siblings('.help-block').html('{$lang["msg_require"]}');
            return false;
        }

        
        $.post("{:cmf_url('api/guestbook/addmsg')}", $('#theForm').serialize(), function(data) {
            // layer.msg(data.msg);    //提示信息
           

            //留言是否成功
            if( data.code==1 ){
                $('.msg_sub').siblings('.help-block').html(data.msg);
                var time = data.wait+'000';
                setTimeout(function(){location.reload()},time);    //数秒后刷新页面
            }
        }, 'JSON');
    }



</script>

